﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>超市进销存管理系统</title>
<link rel="stylesheet" type="text/css" href="css/style.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/ddaccordion.js"></script>
<script type="text/javascript" src="js/jconfirmaction.jquery.js"></script>

<script type="text/javascript">
	
	$(document).ready(function() {
		$('.ask').jConfirmAction();
	});
</script>
<script type="text/javascript" src="js/jquery-1.8.3.js"></script>
<script type="text/javascript">
	 /*$(function() {
		$("#username").blur(function(){
		alert()
	});
	});*/
	
	  function showErrMsg($obj, msg) {
	  	
        if($obj.next() != "undefined") {
        	
          $obj.next().remove();
        }
        var $newErrMsg = $("<span></span>");
        $newErrMsg.html("<font color='red'>" + msg + "</font>");
        //      $obj.after($newErrMsg);
        $obj.after($newErrMsg);
        
      }
      function test() {
      alert("12")
       $.ajax({        	
            type: "post",        //type：(string)请求方式，POST或GET        
            dataType: "json",    //dataType：(string)预期返回的数据类型。xml,html,json,text等
            url: "/Myservlet.do",  //url：(string)发送请求的地址，可以是服务器页面也可以是WebService动作。
            success: function (msg) {
                var str = "";
               /*  for (i in msg) {
                    str += "<tr><td>" + msg[i].id + "</td><td>" + msg[i].name + "</td><td>"
                    + msg[i].cla + "</td><td>" + msg[i].sex + "</td><td>" + msg[i].tel + "</td></tr>";
                } */
                showErrMsg($("#password"), "aaaaaaa");
                //$("tbody").append(str);
            }
        });
      }
      function check() {
        var errCode = 0; //如果有任何一个错误的时候，将错误代码增加1
        var firstNameVal = $("#username").val();
        var userPassVal = $("#password").val();
       
    
        if(firstNameVal == "") {
          showErrMsg($("#username"), "名字不能为空！");
         
          errCode++;
        }
        else{
        	$("#username").next().remove();
        }
        if(userPassVal=="") {
        
          showErrMsg($("#password"), "密码不能为空！");          
          errCode++;
        }else{
        	$("#password").next().remove();
        }    
       
        if(errCode > 0) {
          return false;
        } else {
          return true;
        }
     
      }

      $(function() {
        $("#userID").blur(check);
        $("#username").blur(check);
        $("#password").blur(check);
		
    	$("#button").click(test);   
        $("#userinfo").submit(check);        
      
           
        
       /*  var data = {demo: "#userID"};
        var str = JSON.stringify(data); //"{"demo":"test"}"
        $.parseJSON(str); 
        alert(str);    */
      });
     
</script>

<script language="javascript" type="text/javascript" src="js/niceforms.js"></script>
<link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" />

</head>
<body>
<div id="main_container">

	<div class="header_login">
    <div class="logo"><a href="#"></a></div>
    
    </div>

     
         <div class="login_form">
         
         <h3 style="padding-left: 250px;">超市进销存管理系统</h3>
         
        
         
         <form id="userinfo" action="Myservlet.do" method="post" class="niceform" >
         
                <fieldset>
                	<dl>
                        <dt><label for="email">员工号:</label></dt>
                        <dd><input type="text" name="userID" id="userID" size="40" /></dd>
                    </dl>
                    <dl>
                        <dt><label for="email">员工姓名:</label></dt>
                        <dd><input type="text" name="username" id="username" size="40" /></dd>
                    </dl>
                    <dl>
                        <dt><label for="password">密码:</label></dt>
                        <dd><input type="password" name="password" id="password" size="40" /></dd>
                    </dl>
                    
                    <dl>
                        <dt><label></label></dt>
                        <dd>
                    
                        </dd>
                    </dl>
                    
                     <dl class="submit">
                     <input type="button" name="ajax" id="button" value="测试"/>
                     	 <input type="submit" name="submit" id="submit" value="登录" />
                         <a href="register.html" style="text-decoration: none;">
                         	<input type="button" name="submit" id="submit" value="顾客请先注册"/> </a>
                     </dl>
                    
                </fieldset>
                
         </form>
         </div>  
          
	
    
    <div class="footer_login">
    
    	
    	<div class="right_footer_login"></div>
    
    </div>

</div>		
</body>
</html>